package com.ljs.view.panel
{
	import com.ljs.control.MainContent;
	import com.ljs.control.MainControl;
	import com.ljs.define.CharTypeDefine;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class SelectRolePanel extends MovieClip
	{
		private var _role1:MovieClip;
		private var _role2:MovieClip;
		private var _role3:MovieClip;
		private var _role4:MovieClip;
		private var _control:MainControl;
		private var _datapool:MainContent;
		public function SelectRolePanel()
		{
			init();
		}
		
		private function init()
		{
			_role1=getChildByName("mcRole1") as MovieClip;
			_role2=getChildByName("mcRole2") as MovieClip;
			_role3=getChildByName("mcRole3") as MovieClip;
			_role4=getChildByName("mcRole4") as MovieClip;
			
			_role1.addEventListener(MouseEvent.CLICK,onRole1Click);
			_role2.addEventListener(MouseEvent.CLICK,onRole2Click);
			_role3.addEventListener(MouseEvent.CLICK,onRole3Click);
			_role4.addEventListener(MouseEvent.CLICK,onRole4Click);
		}
		
		public function setControl(c:MainControl)
		{
			_control=c;
		}
		
		public function setDataPool(c:MainContent)
		{
			_datapool=c;
		}
		
		private function onRole1Click(e:MouseEvent)
		{
			_datapool.mainVo.charType=CharTypeDefine.CHAR_1;
			_control.gotoGame();
		}
		
		private function onRole2Click(e:MouseEvent)
		{
			_datapool.mainVo.charType=CharTypeDefine.CHAR_2;
			_control.gotoGame();
		}
		
		private function onRole3Click(e:MouseEvent)
		{
			_datapool.mainVo.charType=CharTypeDefine.CHAR_3;
			_control.gotoGame();
		}
		
		private function onRole4Click(e:MouseEvent)
		{
			_datapool.mainVo.charType=CharTypeDefine.CHAR_4;
			_control.gotoGame();
		}
		
		public function destroy()
		{
			_role1.removeEventListener(MouseEvent.CLICK,onRole1Click);
			_role2.removeEventListener(MouseEvent.CLICK,onRole2Click);
			_role3.removeEventListener(MouseEvent.CLICK,onRole3Click);
			_role4.removeEventListener(MouseEvent.CLICK,onRole4Click);
		}
	}
}